﻿namespace ConsoleApplication1
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Xml.Schema;
    using System.Xml.Serialization;

    [XmlRoot(Namespace = "http://xml.is.estg.org/schema/DataSchema")]
    public class SerializableList<T> : List<T>
    {
        [XmlAttribute(AttributeName = "schemaLocation", Namespace = "http://www.w3.org/2001/XMLSchema-instance")] 
        public string XsiSchemaLocation = "DataSchema.xsd";
    }

    [XmlRoot(Namespace = "http://xml.is.estg.org/schema/DataSchema")]
    public class SerializableCollection<T> : ICollection<T>
    {
        [XmlAttribute(AttributeName = "schemaLocation", Namespace = "http://www.w3.org/2001/XMLSchema-instance")]
        public string XsiSchemaLocation = "DataSchema.xsd";

        private ICollection<T> _collection = new List<T>();

        public IEnumerator<T> GetEnumerator()
        {
            return _collection.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        public void Add(T item)
        {
           _collection.Add(item);
        }

        public void Clear()
        {
            _collection.Clear();
        }

        public bool Contains(T item)
        {
            return _collection.Contains(item);
        }

        public void CopyTo(T[] array, int arrayIndex)
        {
            _collection.CopyTo(array, arrayIndex);
        }

        public bool Remove(T item)
        {
            return _collection.Remove(item);
        }

        public int Count
        {
            get { return _collection.Count; }
        }

        public bool IsReadOnly
        {
            get { return _collection.IsReadOnly; }
        }
    }
}